package com.leo.algorithm.linked;

/**
 * 反转区间
 */
public class ReverseInterval {

    public static void main(String[] args) {

    }

    // 反转链表中指定的部分
    public static ListNode reverseBetween(ListNode head, int m, int n) {
        // base case
        if (m == 1) {
            return ReverseN.reverse(head, n);
        }
        // 前进到反转的起点触发 base case
        head.setNext(reverseBetween(head.getNext(), m - 1, n - 1));
        return head;
    }

}
